#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

bool check(const char *p)
{
    while(*p) {
        if (*p != '*') return false;
        p++;
    }
    return true;
}

bool isMatch(const char *s, const char *p) {
    if (*p == '\0') return *s == '\0';

    if (!*s && check(p)) return true;
    if (!*s || !*p) return false;
    
    if (*p == '?') {
        return isMatch(s+1, p+1);
    } else if (*p == '*') {
        s--;
        do {
            s++;
            if (isMatch(s, p+1)) return true;
        } while (*s);
    } else {
        if (*s != *p &&  *p != '?') return false;
        return isMatch(s+1, p+1);
    }

    return false;
}
    

int main(int argc, char **argv)
{

    cout << "-----------------Test 1--------------------" << endl;
    cout << isMatch("b", "??") << endl;


    cout << "-----------------Test 2--------------------" << endl;


    cout << "-----------------Test 3--------------------" << endl;


    cout << "-----------------Test 4--------------------" << endl;


    cout << "-----------------Test 5--------------------" << endl;



}
